"""
Web
"""

import streamlit as st
from src.web.components.header import Header
from src.web.components.sidebar import Sidebar
from src.web.components.file_uploader import FileUploader

class UploadPage:
    """"""
    
    def __init__(self):
        self.file_uploader = FileUploader()
    
    def render(self):
        """"""
        # 
        Header.render()
        
        # 
        settings = Sidebar.render()
        
        # 
        col1, col2 = st.columns([3, 1])
        
        with col1:
            # 
            uploaded_file_path = self.file_uploader.render()
            
            if uploaded_file_path:
                st.success(" ")
                
                # 
                st.header(" ")
                
                col_a, col_b = st.columns(2)
                
                with col_a:
                    # 
                    st.subheader(" ")
                    
                    enable_transcript = st.checkbox("", value=True)
                    if enable_transcript:
                        transcript_only = st.checkbox("", value=False)
                        if transcript_only:
                            st.session_state.settings['transcript_only'] = True
                
                with col_b:
                    # 
                    st.subheader(" ")
                    
                    enable_summary = st.checkbox("AI", value=True, disabled=st.session_state.settings.get('transcript_only', False))
                    if enable_summary:
                        enable_keywords = st.checkbox("", value=True)
                        enable_chapters = st.checkbox("", value=True)
                        
                        st.session_state.settings['enable_keywords'] = enable_keywords
                        st.session_state.settings['enable_chapters'] = enable_chapters
                
                # 
                st.markdown("---")
                
                col_start, col_back = st.columns([3, 1])
                
                with col_start:
                    if st.button(" ", type="primary", use_container_width=True):
                        # session state
                        st.session_state.uploaded_file_path = uploaded_file_path
                        st.session_state.current_page = 'processing'
                        st.rerun()
                
                with col_back:
                    if st.button(" ", use_container_width=True):
                        st.session_state.current_page = 'main'
                        st.rerun()
            
            else:
                # 
                st.info(" ")
                
                if st.button(" ", use_container_width=True):
                    st.session_state.current_page = 'main'
                    st.rerun()
        
        with col2:
            st.header(" ")
            
            st.markdown("""
            ###  
            
            1. **** - 
            2. **** - Whisper
            3. **** - 
            4. **AI** - Ollama
            5. **** - 
            
            ### ⏱ 
            
            - **** (< 10): 1-3
            - **** (10-30): 3-8  
            - **** (30-60): 8-15
            - **** (> 1): 15
            
            ###  
            
            - 
            - 
            - GPU
            """)
            
            # 
            with st.expander(" "):
                st.json(st.session_state.settings)